package bot

import "net/http"

// cobot 后端 mock

func ConfigHttpHandler() {

	cobotHandler := NewCobotHandler()
	http.Handle("/cobot/getCobotStatus", http.HandlerFunc(cobotHandler.GetCobotStatus))
	http.Handle("/cobot/login", http.HandlerFunc(cobotHandler.Connect))
	http.Handle("/cobot/loginOut", http.HandlerFunc(cobotHandler.Disconnect))

	http.Handle("/cobot/powerOn", http.HandlerFunc(cobotHandler.PowerOn))
	http.Handle("/cobot/powerOff", http.HandlerFunc(cobotHandler.PowerOff))

	http.Handle("/cobot/enableCobot", http.HandlerFunc(cobotHandler.EnableRobot))
	http.Handle("/cobot/disableCobot", http.HandlerFunc(cobotHandler.DisableRobot))

	http.Handle("/cobot/resetAlarm", http.HandlerFunc(cobotHandler.ResetAlarm))

	http.Handle("/cobot/runWeldingProgram", http.HandlerFunc(cobotHandler.RunWeldingProgram))
	http.Handle("/cobot/suspendWeldingProgram", http.HandlerFunc(cobotHandler.SuspendWeldingProgram))
	http.Handle("/cobot/continueWeldingProgram", http.HandlerFunc(cobotHandler.ContinueWeldingProgram))
	http.Handle("/cobot/stopWeldingProgram", http.HandlerFunc(cobotHandler.StopWeldingProgram))

	http.Handle("/cobot/getTeachingPoint", http.HandlerFunc(cobotHandler.GetTeachingPoint))
	http.Handle("/cobot/setCobotRapidRate", http.HandlerFunc(cobotHandler.StopWeldingProgram))

	welderHandler := NewWelderHandler()

	http.Handle("/welder/getCurrentlyCraftParameter", http.HandlerFunc(welderHandler.GetCurrentlyCraftParameter))
	http.Handle("/welder/craftParametersSelection", http.HandlerFunc(welderHandler.CraftParametersSelection))

	http.Handle("/welder/weldingCommonControl", http.HandlerFunc(welderHandler.CommonControl))
	http.Handle("/welder/queryAlarm", http.HandlerFunc(welderHandler.QueryAlarm))

	http.Handle("/welder/saveCraftParameters", http.HandlerFunc(welderHandler.SaveCraftParameters))

	// 获取工艺数据
	http.Handle("/welder/getCraftSelector", http.HandlerFunc(welderHandler.GetCraftSelector))
	// 获取所有工艺参数
	http.Handle("/welder/getCraftParametersList", http.HandlerFunc(welderHandler.GetCraftParametersList))

	http.Handle("/welder/getCraftParametersListBySelect", http.HandlerFunc(welderHandler.GetCraftParametersListBySelect))

	http.Handle("/welder/weavingWeldSwitch", http.HandlerFunc(welderHandler.WeavingWeldSwitch))

	http.Handle("/welder/queryWeavingWeldParameter", http.HandlerFunc(welderHandler.QueryWeavingWeldParameter))

	http.Handle("/welder/updateWeavingWeldParameter", http.HandlerFunc(welderHandler.UpdateWeavingWeldParameter))

	http.Handle("/welder/setArcingParameters", http.HandlerFunc(welderHandler.SetArcingParameters))
	http.Handle("/welder/setQuenchingResidenceTime", http.HandlerFunc(welderHandler.SetQuenchingResidenceTime))

	programHander := NewProgramHandler()
	http.Handle("/program/getCurrentRunProgram", http.HandlerFunc(programHander.GetCurrentRunProgram))
	http.Handle("/program/getProgramList", http.HandlerFunc(programHander.GetProgramList))

	fileHandler := NewFileHandler()
	http.Handle("/file/uploadAudio", http.HandlerFunc(fileHandler.UploadAudio))
	http.Handle("/file/download", http.HandlerFunc(fileHandler.Download))

}

func ConfigWithMux(mux *http.ServeMux) {

	cobotHandler := NewCobotHandler()
	mux.Handle("/cobot/getCobotStatus", http.HandlerFunc(cobotHandler.GetCobotStatus))
	mux.Handle("/cobot/login", http.HandlerFunc(cobotHandler.Connect))
	mux.Handle("/cobot/loginOut", http.HandlerFunc(cobotHandler.Disconnect))

	mux.Handle("/cobot/powerOn", http.HandlerFunc(cobotHandler.PowerOn))
	mux.Handle("/cobot/powerOff", http.HandlerFunc(cobotHandler.PowerOff))

	mux.Handle("/cobot/enableCobot", http.HandlerFunc(cobotHandler.EnableRobot))
	mux.Handle("/cobot/disableCobot", http.HandlerFunc(cobotHandler.DisableRobot))

	mux.Handle("/cobot/resetAlarm", http.HandlerFunc(cobotHandler.ResetAlarm))

	mux.Handle("/cobot/runWeldingProgram", http.HandlerFunc(cobotHandler.RunWeldingProgram))
	mux.Handle("/cobot/suspendWeldingProgram", http.HandlerFunc(cobotHandler.SuspendWeldingProgram))
	mux.Handle("/cobot/continueWeldingProgram", http.HandlerFunc(cobotHandler.ContinueWeldingProgram))
	mux.Handle("/cobot/stopWeldingProgram", http.HandlerFunc(cobotHandler.StopWeldingProgram))

	mux.Handle("/cobot/getTeachingPoint", http.HandlerFunc(cobotHandler.GetTeachingPoint))
	mux.Handle("/cobot/setCobotRapidRate", http.HandlerFunc(cobotHandler.StopWeldingProgram))

	welderHandler := NewWelderHandler()

	mux.Handle("/welder/getCurrentlyCraftParameter", http.HandlerFunc(welderHandler.GetCurrentlyCraftParameter))
	mux.Handle("/welder/craftParametersSelection", http.HandlerFunc(welderHandler.CraftParametersSelection))

	mux.Handle("/welder/weldingCommonControl", http.HandlerFunc(welderHandler.CommonControl))
	mux.Handle("/welder/queryAlarm", http.HandlerFunc(welderHandler.QueryAlarm))

	mux.Handle("/welder/saveCraftParameters", http.HandlerFunc(welderHandler.SaveCraftParameters))

	// 获取工艺数据
	mux.Handle("/welder/getCraftSelector", http.HandlerFunc(welderHandler.GetCraftSelector))
	// 获取所有工艺参数
	mux.Handle("/welder/getCraftParametersList", http.HandlerFunc(welderHandler.GetCraftParametersList))

	mux.Handle("/welder/getCraftParametersListBySelect", http.HandlerFunc(welderHandler.GetCraftParametersListBySelect))

	mux.Handle("/welder/weavingWeldSwitch", http.HandlerFunc(welderHandler.WeavingWeldSwitch))

	mux.Handle("/welder/queryWeavingWeldParameter", http.HandlerFunc(welderHandler.QueryWeavingWeldParameter))

	mux.Handle("/welder/updateWeavingWeldParameter", http.HandlerFunc(welderHandler.UpdateWeavingWeldParameter))

	mux.Handle("/welder/setArcingParameters", http.HandlerFunc(welderHandler.SetArcingParameters))
	mux.Handle("/welder/setQuenchingResidenceTime", http.HandlerFunc(welderHandler.SetQuenchingResidenceTime))

	programHander := NewProgramHandler()
	mux.Handle("/program/getCurrentRunProgram", http.HandlerFunc(programHander.GetCurrentRunProgram))
	mux.Handle("/program/getProgramList", http.HandlerFunc(programHander.GetProgramList))

	chatHandler := NewChatHandler()
	mux.Handle("/chat/openChat", http.HandlerFunc(chatHandler.OpenChat))

	fileHandler := NewFileHandler()
	mux.Handle("/file/uploadAudio", http.HandlerFunc(fileHandler.UploadAudio))
	mux.Handle("/file/download", http.HandlerFunc(fileHandler.Download))

}

// func ConfigHttpHandlerMux(mux http.ServeMux) {
// 	fileHandler := NewFileHandler()
// 	mux.HandleFunc("/file/UploadAudio", http.HandlerFunc(fileHandler.UploadAudio))
// }
